#ifndef	MSOCKET
#define	MSOCKET
#include "winsock2.h"

class	MCSocket
{
public:
	MCSocket () ;
	~MCSocket () ;
	bool	Create ( int type = SOCK_DGRAM , int protocol = IPPROTO_IP ) ;
	bool	Bind ( u_short port ) ;
	bool	Listen ( int n ) ;
	bool	Accept ( sockaddr_in& addr ) ;
	bool	Accept ( char *saddr , int& port ) ;
	bool	Connect ( const char* saddr , u_short port ) ;
	int		Recv ( char* buffer , int len , int type = 0 ) ;
	int		Send ( const char* buffer , int len , int type = 0 ) ;
	int		RecvFrom ( char* saddr , int& Port , char* buffer , int len , int flags = 0 ) ;
	int		SendTo ( const char* saddr , int Port , char* buffer , int len , int flags = 0 ) ;
	bool	Close () ;

	CString	GetLocalIp() ;
private:
	SOCKET	m_socket ;
};

#endif
